/*    */ package com.wzh.action.control.book;
/*    */ 
/*    */ import com.opensymphony.xwork2.ActionContext;
/*    */ import com.opensymphony.xwork2.ActionSupport;
/*    */ import com.wzh.bean.PageView;
/*    */ import com.wzh.bean.QueryResult;
/*    */ import com.wzh.bean.book.BookType;
/*    */ import com.wzh.constant.CommonConstant;
/*    */ import com.wzh.service.bookinfo.booktype.BookTypeService;
/*    */ import javax.annotation.Resource;
/*    */ import org.springframework.stereotype.Controller;
/*    */ 
/*    */ @Controller
/*    */ public class BookTypeManageAction extends ActionSupport
/*    */ {
/*    */   private static final long serialVersionUID = 1L;
/*    */ 
/*    */   @Resource
/*    */   private BookTypeService bookTypeService;
/* 23 */   private int page = 1;
/*    */   private BookType bookType;
/*    */ 
/*    */   public BookType getBookType()
/*    */   {
/* 28 */     return this.bookType;
/*    */   }
/*    */ 
/*    */   public void setBookType(BookType bookType)
/*    */   {
/* 34 */     this.bookType = bookType;
/*    */   }
/*    */ 
/*    */   public int getPage()
/*    */   {
/* 40 */     return this.page;
/*    */   }
/*    */ 
/*    */   public void setPage(int page)
/*    */   {
/* 46 */     this.page = page;
/*    */   }
/*    */ 
/*    */   public String index()
/*    */   {
/* 52 */     PageView pageView = new PageView(CommonConstant.MAXRESULT, this.page);
/*    */ 
/* 54 */     int firstIndex = (this.page - 1) * CommonConstant.MAXRESULT;
/*    */ 
/* 56 */     QueryResult qr = this.bookTypeService.getScrollData(firstIndex, CommonConstant.MAXRESULT);
/* 57 */     pageView.setRecords(qr.getResultlist());
/* 58 */     pageView.setTotalrecords((int)qr.getTotalrecord());
/* 59 */     ActionContext.getContext().put("pageView", pageView);
/* 60 */     return "index";
/*    */   }
/*    */ 
/*    */   public String edit() {
/* 64 */     this.bookType = ((BookType)this.bookTypeService.find(this.bookType.getId()));
/* 65 */     return "edit";
/*    */   }
/*    */ 
/*    */   public String update() {
/* 69 */     if (this.bookTypeService.findTypeByFilename(this.bookType.getFilename()) != null) {
/* 70 */       ActionContext.getContext().put("message", "该文件名已经存在，请重新修改");
/* 71 */       ActionContext.getContext().put("urladdress", "/control/booktype/edit");
/*    */     } else {
/* 73 */       this.bookTypeService.update(this.bookType);
/* 74 */       ActionContext.getContext().put("message", "更新成功");
/* 75 */       ActionContext.getContext().put("urladdress", "/control/booktype/index");
/*    */     }
/*    */ 
/* 78 */     return "message";
/*    */   }
/*    */ }

/* Location:           C:\work\apache-tomcat-7.0.55\webapps\ROOT\WEB-INF\classes\
 * Qualified Name:     com.wzh.action.control.book.BookTypeManageAction
 * JD-Core Version:    0.6.1
 */